import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong/latlong.dart';
import 'package:note_life/color.dart';

class MapView extends StatefulWidget{
  @override
  createState()=>_MapView();
}
class _MapView extends State<MapView>{
  @override
  Widget build(BuildContext context) {
    return buildFlutterMap();
  }

  FlutterMap buildFlutterMap() {
    return FlutterMap(
      options: MapOptions(
        center: LatLng(38.0421637891, 114.5081160456),
        zoom: 15.0,
        interactive: false,
        maxZoom: 15.0,
        minZoom: 15.0,
      ),
      layers: [
        TileLayerOptions(
          urlTemplate: "https://api.tiles.mapbox.com/v4/"
              "{id}/{z}/{x}/{y}@2x.png?access_token={accessToken}",
          additionalOptions: {
            'accessToken':
            'pk.eyJ1Ijoic3VudGFyIiwiYSI6ImNqcGRmNzRmcTA0MWUzcW9hdTE0em4wMWYifQ.Sbhq2LVCaUESy2IP5AeDaQ',
            'id': 'mapbox.streets',
          },
        ),
        PolylineLayerOptions(polylines: [
          Polyline(points: [
            LatLng(38.0421637891, 114.5081160456),
            LatLng(38.0413441832, 114.5080999523),
            LatLng(38.0413726132, 114.5091695706),
            LatLng(38.0413979619, 114.5092124859),
            LatLng(38.0414613338, 114.5092822233),
            LatLng(38.0416303253, 114.5093734184),
            LatLng(38.0417528439, 114.5094431559),
            LatLng(38.0421330726, 114.5094485203),
          ], color: AppColor.BLUE_COLOR, strokeWidth: 3.0),
        ]),
        MarkerLayerOptions(markers: [
          Marker(
              point: LatLng(38.0421637891, 114.5081160456),
              builder: (context) => Container(
                child: Icon(
                  Icons.location_on,
                  color: AppColor.GREEN_COLOR,
                ),
              )),
          Marker(
              point: LatLng(38.0421330726, 114.5094485203),
              builder: (context) => Container(
                child: Icon(
                  Icons.location_on,
                  color: AppColor.BLUE_COLOR,
                ),
              )),
        ])
      ],
    );
  }
}